<?php

/**
 * breedable_core_constants()
 *
 * The core WPEC constants necessary to start loading
 */
function breedable_core_constants() {
	if(!defined('BREEDABLE_URL'))
		define( 'BREEDABLE_URL',       plugins_url( '', __FILE__ ) );
	// Define Plugin version
	define( 'BREEDABLE_VERSION', '3.8.9.5' );
	define( 'BREEDABLE_MINOR_VERSION', '649230' );
	define( 'BREEDABLE_PRESENTABLE_VERSION', '3.8.9.5' );
	define( 'BREEDABLE_DB_VERSION', 3 );

	// Define Debug Variables for developers
	define( 'BREEDABLE_DEBUG', false );

	// Images URL
	define( 'BREEDABLE_CORE_IMAGES_URL',  BREEDABLE_URL . '/assets/images' );
	define( 'BREEDABLE_CORE_IMAGES_PATH', BREEDABLE_FILE_PATH . '/assets/images' );

	// JS URL
	define( 'BREEDABLE_CORE_JS_URL',  BREEDABLE_URL . '/assets/js' );
	define( 'BREEDABLE_CORE_JS_PATH', BREEDABLE_FILE_PATH . '/assets/js' );
}

/**
 * breedable_core_version_processing()
 */
function breedable_core_constants_version_processing() {
	global $wp_version;

	$version_processing = str_replace( array( '_', '-', '+' ), '.', strtolower( $wp_version ) );
	$version_processing = str_replace( array( 'alpha', 'beta', 'gamma' ), array( 'a', 'b', 'g' ), $version_processing );
	$version_processing = preg_split( "/([a-z]+)/i", $version_processing, -1, PREG_SPLIT_DELIM_CAPTURE );

	array_walk( $version_processing, create_function( '&$v', '$v = trim($v,". ");' ) );

	define( 'IS_WP25', version_compare( $version_processing[0], '2.5', '>=' ) );
	define( 'IS_WP27', version_compare( $version_processing[0], '2.7', '>=' ) );
	define( 'IS_WP29', version_compare( $version_processing[0], '2.9', '>=' ) );
	define( 'IS_WP30', version_compare( $version_processing[0], '3.0', '>=' ) );
}

/**
 * breedable_core_is_multisite()
 *
 * Checks if this is a multisite installation of WordPress
 *
 * @global object $wpdb
 * @return bool
 */
function breedable_core_is_multisite() {
	global $wpdb;

	if ( defined( 'IS_WPMU' ) )
		return IS_WPMU;

	if ( isset( $wpdb->blogid ) )
		$is_multisite = 1;
	else
		$is_multisite = 0;

	define( 'IS_WPMU', $is_multisite );

	return (bool)$is_multisite;
}

/**
 * breedable_core_constants_table_names()
 *
 * List globals here for proper assignment
 *
 * @global string $table_prefix
 * @global object $wpdb
 */
function breedable_core_constants_table_names() {
	global $table_prefix, $wpdb;

	// Use the DB method if it's around
	if ( !empty( $wpdb->prefix ) )
		$wp_table_prefix = $wpdb->prefix;

	// Fallback on the wp_config.php global
	else if ( !empty( $table_prefix ) )
		$wp_table_prefix = $table_prefix;

	// the WPSC meta prefix, used for the product meta functions.
	define( 'BREEDABLE_META_PREFIX', '_breedable_' );

	// These tables are required, either for speed, or because there are no
	// existing WordPress tables suitable for the data stored in them.
	define( 'BREEDABLE_TABLE_SUBMITED_FORM_DATA',     "{$wp_table_prefix}breedable_submited_form_data" );

}

/***
 * breedable_core_setup_globals()
 *
 * Initialize the breedable query vars, must be a global variable as we
 * cannot start it off from within the wp query object.
 * Starting it in wp_query results in intractable infinite loops in 3.0
 */
function breedable_core_setup_globals()
{
}
